package com.yuxi.common;

/**
*    @author com.yuxi
*    @Date 2023-10-18 23:45:30
*    @description 附加数据填充
*/

import java.util.HashSet;
import java.util.Set;
import java.util.stream.Collectors;

public class FullConfigKeyConst {

    /**
    *  填充员工权限组详情
    */
    public final static String ADMIN_PERMISSION_GROUP_FULL_DETAIL_KEY = "ADMIN_PERMISSION_GROUP_FULL_DETAIL";
    /**
    *  填充操作日志记录详情
    */
    public final static String SYS_OPER_LOG_FULL_DETAIL_KEY = "SYS_OPER_LOG_FULL_DETAIL";
    /**
    *  填充产品列表
    */
    public final static String PRODUCT_FULL_LIST_KEY = "PRODUCT_FULL_LIST";
    /**
    *  填充产品详情
    */
    public final static String PRODUCT_FULL_DETAIL_KEY = "PRODUCT_FULL_DETAIL";
    /**
    *  填充合同伙伴列表
    */
    public final static String PARTNER_FULL_LIST_KEY = "PARTNER_FULL_LIST";
    /**
    *  填充系统用户详情
    */
    public final static String ADMIN_FULL_DETAIL_KEY = "ADMIN_FULL_DETAIL";
    /**
    *  填充员工权限组列表
    */
    public final static String ADMIN_PERMISSION_GROUP_FULL_LIST_KEY = "ADMIN_PERMISSION_GROUP_FULL_LIST";
    /**
    *  填充权限组列表
    */
    public final static String PERMISSION_GROUP_FULL_LIST_KEY = "PERMISSION_GROUP_FULL_LIST";
    /**
    *  填充基础信息详情
    */
    public final static String BASE_INFO_FULL_DETAIL_KEY = "BASE_INFO_FULL_DETAIL";
    /**
    *  填充权限组权限关联详情
    */
    public final static String GROUP_RIGHTS_FULL_DETAIL_KEY = "GROUP_RIGHTS_FULL_DETAIL";
    /**
    *  填充权限组详情
    */
    public final static String PERMISSION_GROUP_FULL_DETAIL_KEY = "PERMISSION_GROUP_FULL_DETAIL";
    /**
    *  填充广告图列表
    */
    public final static String BANNER_FULL_LIST_KEY = "BANNER_FULL_LIST";
    /**
    *  填充荣誉详情
    */
    public final static String HONOR_FULL_DETAIL_KEY = "HONOR_FULL_DETAIL";
    /**
    *  填充荣誉列表
    */
    public final static String HONOR_FULL_LIST_KEY = "HONOR_FULL_LIST";
    /**
    *  填充产品分类列表
    */
    public final static String PRODUCT_TYPE_FULL_LIST_KEY = "PRODUCT_TYPE_FULL_LIST";
    /**
    *  填充操作日志记录列表
    */
    public final static String SYS_OPER_LOG_FULL_LIST_KEY = "SYS_OPER_LOG_FULL_LIST";
    /**
    *  填充权限组权限关联列表
    */
    public final static String GROUP_RIGHTS_FULL_LIST_KEY = "GROUP_RIGHTS_FULL_LIST";
    /**
    *  填充广告图详情
    */
    public final static String BANNER_FULL_DETAIL_KEY = "BANNER_FULL_DETAIL";
    /**
    *  填充基础信息列表
    */
    public final static String BASE_INFO_FULL_LIST_KEY = "BASE_INFO_FULL_LIST";
    /**
    *  填充产品分类详情
    */
    public final static String PRODUCT_TYPE_FULL_DETAIL_KEY = "PRODUCT_TYPE_FULL_DETAIL";
    /**
    *  填充系统用户列表
    */
    public final static String ADMIN_FULL_LIST_KEY = "ADMIN_FULL_LIST";
    /**
    *  填充权限表详情
    */
    public final static String RIGHTS_FULL_DETAIL_KEY = "RIGHTS_FULL_DETAIL";
    /**
    *  填充权限表列表
    */
    public final static String RIGHTS_FULL_LIST_KEY = "RIGHTS_FULL_LIST";
    /**
    *  填充合同伙伴详情
    */
    public final static String PARTNER_FULL_DETAIL_KEY = "PARTNER_FULL_DETAIL";

    public final static String FULL_ALL_KEY = "FULL_ALL";
    public static Set<String> ALL_CONFIG = new HashSet<>();

    static {
        ALL_CONFIG.add(ADMIN_PERMISSION_GROUP_FULL_DETAIL_KEY);
        ALL_CONFIG.add(SYS_OPER_LOG_FULL_DETAIL_KEY);
        ALL_CONFIG.add(PRODUCT_FULL_LIST_KEY);
        ALL_CONFIG.add(PRODUCT_FULL_DETAIL_KEY);
        ALL_CONFIG.add(PARTNER_FULL_LIST_KEY);
        ALL_CONFIG.add(ADMIN_FULL_DETAIL_KEY);
        ALL_CONFIG.add(ADMIN_PERMISSION_GROUP_FULL_LIST_KEY);
        ALL_CONFIG.add(PERMISSION_GROUP_FULL_LIST_KEY);
        ALL_CONFIG.add(BASE_INFO_FULL_DETAIL_KEY);
        ALL_CONFIG.add(GROUP_RIGHTS_FULL_DETAIL_KEY);
        ALL_CONFIG.add(PERMISSION_GROUP_FULL_DETAIL_KEY);
        ALL_CONFIG.add(BANNER_FULL_LIST_KEY);
        ALL_CONFIG.add(HONOR_FULL_DETAIL_KEY);
        ALL_CONFIG.add(HONOR_FULL_LIST_KEY);
        ALL_CONFIG.add(PRODUCT_TYPE_FULL_LIST_KEY);
        ALL_CONFIG.add(SYS_OPER_LOG_FULL_LIST_KEY);
        ALL_CONFIG.add(GROUP_RIGHTS_FULL_LIST_KEY);
        ALL_CONFIG.add(BANNER_FULL_DETAIL_KEY);
        ALL_CONFIG.add(BASE_INFO_FULL_LIST_KEY);
        ALL_CONFIG.add(PRODUCT_TYPE_FULL_DETAIL_KEY);
        ALL_CONFIG.add(ADMIN_FULL_LIST_KEY);
        ALL_CONFIG.add(RIGHTS_FULL_DETAIL_KEY);
        ALL_CONFIG.add(RIGHTS_FULL_LIST_KEY);
        ALL_CONFIG.add(PARTNER_FULL_DETAIL_KEY);
    }

    /**
     * 判断是否要加载对应的key 的数据
     *
     * @param fullConfigSet
     * @param key
     * @return
     */
    public static boolean hasFullData(Set<String> fullConfigSet, String key) {
        return fullConfigSet == null || fullConfigSet.contains(FULL_ALL_KEY) ||
                fullConfigSet.contains(key);
    }

    /**
     * 排除后返回剩下的
     *
     * @param unFullConfigSet
     * @return
     */
    public static Set<String> excludeFullData(Set<String> unFullConfigSet) {
        if (StringUtil.isNullOrEmpty(unFullConfigSet)) {
            return ALL_CONFIG;
        }
        return ALL_CONFIG.stream().filter(item -> unFullConfigSet.stream().noneMatch(one -> item.equalsIgnoreCase(one))).collect(Collectors.toSet());
    }

    /**
     * 从排除后的数据查询是否要加载
     * @param unFullConfigSet
     * @param key
     * @return
     */
    public static boolean hasFullDataFromUnFullData(Set<String> unFullConfigSet,String key) {
        return hasFullData(excludeFullData(unFullConfigSet),key);
    }
}
